package cn.com.huzo.repository.inventory.impl;

import cn.com.huzo.model.entities.inventory.StockInLinesEntity;
import cn.com.huzo.repository.inventory.StockInLinesRepository;
import huzofw.repository.impl.GenericRepositoryImpl;
import huzofw.repository.impl.MyBatisDaoUtils;
import java.util.List;
import java.util.Map;
import org.springframework.stereotype.Repository;

/**
 * 入库单明细数据访问对象。
 *
 * @author 吴旭
 */
@Repository("StockInLinesRepository")
public class StockInLinesRepositoryImpl extends GenericRepositoryImpl<StockInLinesEntity, String>
        implements StockInLinesRepository {

    private final String namespace = "cn.com.huzo.repository.inventory.StockInLinesRepository";

    /**
     * 构造函数,设置the instance to ProductRepositoryImpl.class.
     */
    public StockInLinesRepositoryImpl() {
        super(StockInLinesEntity.class);
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public List<StockInLinesEntity> fetchAllByHeaderId(Long headerId) {
        return getSqlSession().selectList(MyBatisDaoUtils.getMapperQueryId(
                namespace, "fetchAllByHeaderId"), headerId);
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public Integer insertLines(Map<String, Object> filters) {
        return getSqlSession().insert(MyBatisDaoUtils.getMapperQueryId(
                namespace, "insert"), filters);
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public Integer update(StockInLinesEntity instance) {
        return getSqlSession().update(MyBatisDaoUtils.getMapperQueryId(
                namespace, "update"), instance);
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public Integer clearArrivalAllowed(StockInLinesEntity instance) {
        return getSqlSession().update(MyBatisDaoUtils.getMapperQueryId(
                namespace, "clearArrivalAllowed"), instance);
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public Integer fetchForCount(Map<String, Object> filters) {
        return getSqlSession().selectOne(MyBatisDaoUtils.getMapperQueryId(
                namespace, "fetchForCount"), filters);
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public List<StockInLinesEntity> fetchForPage(Map<String, Object> filters) {
        return getSqlSession().selectList(MyBatisDaoUtils.getMapperQueryId(
                namespace, "fetchForPage"), filters);
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public Integer delete(String linesId) {
        return getSqlSession().delete(MyBatisDaoUtils.getMapperQueryId(
                namespace, "delete"), linesId);
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public Integer batchDelete(List<StockInLinesEntity> itemList) {
        return getSqlSession().delete(MyBatisDaoUtils.getMapperQueryId(
                namespace, "batchDelete"), itemList);
    }
    
    /**
     * {@inheritDoc}
     */
    @Override
    public Integer delete_for_sync_lines(Long headerId) {
        return getSqlSession().delete(MyBatisDaoUtils.getMapperQueryId(
                namespace, "delete_for_sync_lines"), headerId);
    }
}
